{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import math"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Point:\n",
    "    def __init__(self,x=0,y=0):\n",
    "        self.x=x\n",
    "        self.y=y\n",
    "        \n",
    "    def distance_from_origin(self):\n",
    "        return math.hypot(self.x,self.y)\n",
    "    \n",
    "    def __eq__(self,other):\n",
    "        return self.x==other.x and self.y==other.y\n",
    "    \n",
    "    def __repr__(self):\n",
    "        return \"Point({0.x!r},{0.y!r})\".format(self)\n",
    "    \n",
    "    def __str__(self):\n",
    "        return \"({0.x!r},{0.y!r})\".format(self)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Circle(Point):\n",
    "    def __init__(self,radius,x=0,y=0):\n",
    "        super().__init__(x,y)\n",
    "        self.radius=radius\n",
    "\n",
    "    def edge_distance_from_origin(self):\n",
    "        return abs(self.distance_from_origin()-self.radius)\n",
    "\n",
    "    def area(self):\n",
    "        return math.pi*(self.radius**2)\n",
    "\n",
    "    def circumference(self):\n",
    "        return 2*math.pi*self.radius\n",
    "\n",
    "    def __eq__(self, other):\n",
    "        return self.radius==other.radius and super().__eq__(other)\n",
    "\n",
    "    def __repr__(self):\n",
    "        return \"Circle({0.radius!r},{0.x!r},{0.y!r}\".format(self)\n",
    "\n",
    "    def __str__(self):\n",
    "        return repr(self)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a=Point()\n",
    "repr(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "b=Point(3,4)\n",
    "str(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "b.distance_from_origin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "str(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "b.x=-19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "str(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a==b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "p=Point(28,45)\n",
    "c=Circle(5,28,45)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "p.distance_from_origin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "c.distance_from_origin()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
